<template>
  <div>
    <h2>vue-resource  post</h2>
    用户名：<input type="text" v-model="user_name"><br/>
    密码：<input type="text" v-model="password"><br/>
    <button @click="register">注册</button><br/>

    <form action="http://localhost:8000/register" method="post">
      用户名：<input type="text" name="user_name" /><br />
      密码：<input type="text" name="password" /><br />
      <input type="submit" value="提交" />
    </form>
  </div>
</template>

<script>
  export default {
    data(){
      return{
        user_name:"",
        password:"",
      };
    },
    methods:{
      register(){
        const user = {
          user_name : this.user_name,
          password : this.password,
        };
        console.log(user);
        this.$http.post("http://localhost:8000/register",user,{
          emulateJSON:true,
        }).then((res)=>{
          console.log(res);
        });
      },
    }
  }
</script>

<style lang="scss" scoped>

</style>